package cn.com.taiji.learn.sshelloworld.service.impl;
import cn.com.taiji.learn.sshelloworld.domain.User;
import cn.com.taiji.learn.sshelloworld.service.IEmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;

import org.springframework.stereotype.Service;

@Service
public class EmailServiceImpl implements IEmailService {
    @Autowired
    private JavaMailSender mailSender;

   @Value("${spring.mail.username}")
   private String from;
    @Override
    public Boolean sendEmail(User user) {

        final SimpleMailMessage email = new SimpleMailMessage();
        email.setFrom(from);
        email.setTo(from);
        email.setSubject("用户注册激活");
        String link="http://localhost:8081/user/verify/";
        email.setText("我的测试发送，请点击超链接进行激活：\r\n"+link+user.getId());
        mailSender.send(email);
        return true;
    }
}